<template>
  <div class="container contract-review mb70">
    <p class="bread">
      <a :href="href" class="font-s-18">{{orderName}}</a> >
      <a href="javascript:void(0);" class="font-s-16">详情</a>
    </p>
    <div class="bg-c-fff box-border">
      <h3 class="tm-title">交易监控订单详情</h3>
      <step :stepData="stepData" :stepNum="stepNum" @stepRouter="stepRouter"></step>
    </div>
    <div class="content">
      <div class="box bg-c-fff box-border tc">
        <div class="file-box auto box-border">
          <ul>
            <li v-for="item in fileList" class="ico">
              <span class="iconfont icon-file-copy icon"></span>
              <a :href="item.address" download>{{item.address | fileName}}</a>
            </li>
          </ul>
        </div>
        <p class="tc state">状态：
          <span v-if="report === 0">待上传</span>
          <span v-else>已上传</span>
        </p>
        <button class="blue-button xl-btn-css" @click="onNextClick">下一步</button>
      </div>
    </div>
  </div>
</template>
<script type="text/javascript">
import Step from '../components/Step'
export default {
  components: {
    Step
  },
  data() {
    return {
      stepNum: 0,
      stepData: [{
        name: '查看资质审查报告'
      }, {
        name: '查看审查合同'
      }, {
        name: '监控师绘制流程图'
      }, {
        name: '监控员交易监控'
      }],
      report: 0,
      fileList: [],
      orderName: '',
      href: '',
      status: ''
    }
  },
  mounted() {
    this.$http.post('/transactionMonitorSer/sys/read/detail', {
      id: this.$route.query.id
    }).then(data => {
      if (data.data.httpCode === 200) {
        this.fileList = data.data.data.fileList
        this.report = data.data.data.reportNum
        this.status = data.data.data.status
      }
    }).catch(err => {
      console.log(err)
      this.$toasted.show('网络出错')
    })
    if (this.$route.query.type === 'business') {
      this.orderName = '业务管理部-交易监控订单管理'
      this.href = '#/index/transaction-order-manage'
    } else if (this.$route.query.type === 'chief') {
      this.orderName = '首席监控师-交易监控订单管理'
      this.href = '#/index/cm-transaction-list'
    } else if (this.$route.query.type === 'businessNotice') {
      this.orderName = '业务管理部-交易监控通知'
      this.href = '#/index/transaction-notice'
    }
  },
  methods: {
    onNextClick() {
      if (this.status >= 3) {
        this.$router.push('/cm-transaction-contract?type=' + this.$route.query.type + '&id=' + this.$route.query.id)
      } else {
        this.$toasted.show('此订单还没有进行到下一步')
      }
    },
    stepRouter(i, name) {
      if (i === 0 && this.status >= 2) {
        this.$router.push('/cm-transaction-aptitude?type=' + this.$route.query.type + '&id=' + this.$route.query.id)
      }
      if (i === 1 && this.status >= 3) {
        this.$router.push('/cm-transaction-contract?type=' + this.$route.query.type + '&id=' + this.$route.query.id)
      }
      if (i === 2 && this.status >= 4) {
        this.$router.push('/cm-transaction-drawing?type=' + this.$route.query.type + '&id=' + this.$route.query.id)
      }
      if (i === 3 && this.status >= 5) {
        this.$router.push('/cm-transaction-flow?type=' + this.$route.query.type + '&id=' + this.$route.query.id)
      }
    }
  },
  filters: {
    fileName(v) {
      return v.split('/')[v.split('/').length - 1]
    }
  }
}

</script>
<style type="text/css" scoped>
.box-border {
  border: 1px solid #ddd;
}

.content {
  margin-bottom: 40px;
}

.content .box {
  margin-top: 20px;
}

.content a {
  margin-top: 40px;
}

.white-button,
.blue-button {
  width: 245px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  margin: 25px 5px 45px 5px;
}

.file-box {
  min-height: 150px;
  line-height: 1;
  width: 600px;
  margin-top: 40px;
}


.state {
  line-height: 35px;
}

.ico {
  margin-top: 40px;
  line-height: 50px;
  margin-bottom: 50px;
  margin-left: 200px;
  text-align: left;
}

.icon {
  font-size: 50px;
  color: #d8e7ff;
  vertical-align: middle;
}

</style>
